/********************************************************************
引脚接线：
PB10 PB11                    ==> 蓝牙RX TX            (Serial.c)
PA1                          ==> 舵机PWM              (PWM_Servo.c)

           手机使用”调试全能王”向蓝牙发信息
*********************************************************************/
#include "stm32f10x.h"                  // Device header
#include "Delay.h"
#include "Serial.h"                     //波特率为9600
#include "Servo.h"
#include "Control.h"

int main(void)
{
	/*模块初始化*/                        	                
	Serial_Init();
	Servo_Init();
	Control_Init();
	
	Close();
	
	Servo_SetAngle1(100);
	Servo_SetAngle2(100);
	
	while (1)
	{
		if(Serial_RxPacket==1)
		{
			Open();
			Servo_SetAngle1(130);
			Delay_ms(500);
			Servo_SetAngle1(100);
			Delay_ms(500);
			Close();
			Serial_RxPacket=0;
		}
		
		if(Serial_RxPacket==2)
		{
			Open();
			
			Servo_SetAngle1(67);
			Delay_ms(500);
			Servo_SetAngle1(100);
			Delay_ms(500);
			Close();
			Serial_RxPacket=0;
		}
		if(Serial_RxPacket==3)
		{
			Open();
			Servo_SetAngle2(66);
			Delay_ms(500);
			Servo_SetAngle2(100);
			Delay_ms(500);
			Close();
			Serial_RxPacket=0;
		}
		if(Serial_RxPacket==4)
		{
			Open();
			Servo_SetAngle2(120);
			Delay_ms(500);
			Servo_SetAngle2(100);
			Delay_ms(500);
			Close();
			Serial_RxPacket=0;
		}
		if(Serial_RxPacket==5)
		{
			Open();
			Servo_SetAngle1(130);
			Servo_SetAngle2(66);
			Delay_ms(500);
			Servo_SetAngle1(100);
			Servo_SetAngle2(100);
			Delay_ms(500);
			Close();
			Serial_RxPacket=0;
		}
		if(Serial_RxPacket==6)
		{
			Open();
			Servo_SetAngle1(67);
			Servo_SetAngle2(120);
			Delay_ms(500);
			Servo_SetAngle1(100);
			Servo_SetAngle2(100);
			Delay_ms(500);
			Close();
			Serial_RxPacket=0;
		}
		__WFI();
	}
}
